package cn.com.lsy.product.lepao.service.impl;

import cn.com.lsy.product.lepao.model.dao.LpAccessoryTblMapper;
import cn.com.lsy.product.lepao.model.dao.LpIconTblMapper;
import cn.com.lsy.product.lepao.model.entities.LpAccessoryTbl;
import cn.com.lsy.product.lepao.model.entities.LpIconTbl;
import cn.com.lsy.product.lepao.model.mt.dao.MtIconMapper;
import cn.com.lsy.product.lepao.model.mt.entities.IconListDto;
import cn.com.lsy.product.lepao.service.IIconService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class IconService implements IIconService {

    @Autowired
    MtIconMapper mtIconMapper;
    @Autowired
    LpIconTblMapper lpIconTblMapper;
    @Autowired
    LpAccessoryTblMapper lpAccessoryTblMapper;

    @Override
    public List<IconListDto> selectList(int typeId) {

        Map<String, Object> where = new HashMap<String, Object>();
        where.put("typeId", typeId);

        return mtIconMapper.selectList(where);
    }

    @Override
    public IconListDto selectInfo(int id) {

        Map<String, Object> where = new HashMap<String, Object>();
        where.put("id", id);

        return mtIconMapper.selectInfo(where);
    }

    @Override
    public boolean update(LpIconTbl param) {

        if (lpIconTblMapper.updateByPrimaryKeySelective(param) > 0) {

            return true;

        } else {

            return false;
        }
    }

    @Override
    public boolean insertAccessory(LpAccessoryTbl param) {

        if (lpAccessoryTblMapper.insertSelective(param) > 0) {

            return true;

        } else {

            return false;
        }
    }

    @Override
    public boolean insert(LpIconTbl param) {

        if (lpIconTblMapper.insertSelective(param) > 0) {

            return true;

        } else {

            return false;
        }
    }

    @Override
    public boolean delete(int id) {

        if (lpIconTblMapper.deleteByPrimaryKey(id) > 0) {

            return true;

        } else {

            return false;
        }
    }
}
